/** @jsxImportSource @emotion/react */
import * as React from "react";
import {CCell, Cell, Table, TableBody, TableRow, Text,} from "customize-easy-ui-component";
import Img_Seal from "../../../images/seal.png";
import {CCellUnit, RepLink} from "../../common/base";
import {usePrefixDataTable} from "../../hook/usePrefixData";
import {config设备概况} from "./orcBase";


export const 检验结论报告= ({ orc, rep,theme } : { orc: any, rep: any,theme:any}
) => {
  //但是不能用：加embed: { 0:  <CCell rowSpan={4}>性能参数</CCell>,  }, 需分解为2个表格/列数不同。const config设备概况上=config设备概况.slice(0, 14);
  const renderUpper=usePrefixDataTable({config: config设备概况, orc, rep, slash:true});
  //性能参数 的插入导致无法使用通常的：const [firstNode,_S]=useThreeColumnView({orc, config:config设备概况,slash:true,});
  return <>
    <div css={{"@media print": {paddingBottom: '3.5rem', pageBreakInside: 'avoid'}}}>
      <Text id={'Conclusion'} variant="h2" css={{textAlign: 'center', marginTop: '1rem',
      }}>压力容器定期检验结论报告</Text>
      <div css={{display: 'flex', justifyContent: 'space-between'}}>
        <Text>单位内部编号：{orc.单位内部编号}</Text>
        <Text>报告编号：{rep.isp.no}</Text>
      </div>
    </div>
    <Table fixed={["5.3%", "12%", "39%", "6.1%", "8%", "%"]}
           css={{borderCollapse: 'collapse', "@media print": {marginTop: '-3.5rem'}}} tight miniw={800}>
      <TableBody>
        <RepLink rep={rep} tag={'Survey'}>
          {renderUpper}
          <TableRow >
            <CCell>检查依据</CCell>
            <CCell colSpan={5}>
              《固定式压力容器安全技术监察规程》（TSG21-2016）
            </CCell>
          </TableRow>
        </RepLink>
        <RepLink rep={rep} tag={'Conclusion'}>
          <TableRow>
            <CCell>问题及其处理</CCell>
            <Cell split={true} colSpan={5}><div css={{minHeight: '3rem', whiteSpace: 'pre-wrap'}}>
              {orc.问题及处 || '／'}
            </div></Cell>
          </TableRow>
        </RepLink>
      </TableBody>
    </Table>
    {检验结论VsWDj({theme, orc, rep})}
    <Text css={{fontSize:'0.7rem'}}>
    </Text>
  </>;
};

//【表格】 【助手】  JSON.parse(orc?._tblFixed??'[]')  【工具】
//也没准可能 组件重复利用的！
export const 检验结论VsWDj= ({theme, orc, rep,nextjycl='定期检验',rysx1='编制'} :{theme: any, orc:any, rep:any,nextjycl?:string,rysx1?:string}
) => {
  return <><Table  fixed={ ["5.3%","21%","9%","%"] } css={ {borderCollapse: 'collapse' } } tight  miniw={800}>
    <TableBody>
      <RepLink rep={rep} tag={'Conclusion'}>
        <TableRow  css={{"@media print": {pageBreakInside: 'avoid',}}}>
          <CCell rowSpan={4}>检验结论</CCell>
          <CCell colSpan={3}>压力容器安全状况等级评定为 &nbsp; {orc.安全评定}</CCell>
        </TableRow>
        <TableRow  css={{"@media print": {pageBreakInside: 'avoid',}}}>
          <CCell rowSpan={2}><Text variant="h4">{orc.检验结论}</Text></CCell>
          <CCell colSpan={2}>允许（监控）使用参数</CCell>
        </TableRow>
        <TableRow>
          <CCell colSpan={2} css={{padding:0}}>
            <Table  fixed={ ["8%","%","8%","38%"] } css={ {borderCollapse: 'collapse', height:'fill-available'} } tight  miniw={800}>
              <TableBody>
                <TableRow >
                  <CCell>压力</CCell>
                  <CCellUnit unit={'MPa'}>{orc.结论压力 || '／'}</CCellUnit>
                  <CCell>介质</CCell>
                  <CCell>{orc.结论介质??'／'}</CCell>
                </TableRow>
                <TableRow >
                  <CCell>温度</CCell>
                  <CCellUnit unit={'℃'}>{orc.结论温度 || '／'}</CCellUnit>
                  <CCell>其它</CCell>
                  <CCell>{orc.结论其它??'／'}</CCell>
                </TableRow>
              </TableBody>
            </Table>
          </CCell>
        </TableRow>
        <TableRow>
          <CCell>下次{nextjycl}日期</CCell>
          <CCell colSpan={2}>{orc.新下检日}</CCell>
        </TableRow>
        <TableRow>
          <CCell  scope="row">说明</CCell>
          <Cell split={true} colSpan={3}><div css={{minHeight: '1rem', whiteSpace: 'pre-wrap'}}>
            {orc.结论说明 || '／'}
          </div></Cell>
        </TableRow>
      </RepLink>
    </TableBody>
  </Table>
    <Table fixed={ ["5.3%","55%","4%","12%","%"] }  css={ {borderCollapse: 'collapse' } }  tight  miniw={800}>
      <TableBody>
        <RepLink rep={rep} tag={'Conclusion'}>
          <TableRow>
            <CCell>检验人员</CCell>
            <CCell colSpan={4}>{orc.检验人IDs}</CCell>
          </TableRow>
          <TableRow>
            <CCell>{rysx1}</CCell>
            <CCell>{orc.检验人IDs}</CCell>
            <CCell>日期</CCell>
            <CCell>{orc.检验日期 || '／'}</CCell>
            <CCell rowSpan={3}>
              <div css={{
                height:'8rem',
                '::before': {
                  filter: 'opacity(30%)',
                  width: '100%',
                  height: '100%',
                  backgroundImage: `url(${Img_Seal})`,
                  content: '" "',
                  position: 'absolute',
                  top: 0,
                  left: 0,
                  backgroundRepeat: 'no-repeat',
                  backgroundPosition: 'center',
                }
              }}>
                <Table  fixed={ ["40%","%"]  } css={ {borderCollapse: 'collapse',height:'fill-available'} }>
                  <TableBody>
                    <TableRow>
                      <CCell css={{border:'none'}}>检验机构核准证号</CCell><CCell css={{border:'none'}}>{rep?.isp?.ispu?.agency?.apno}</CCell>
                    </TableRow>
                    <TableRow>
                      <CCell css={{border:'none'}} colSpan={2}>（检查单位检查专用章或者公章）</CCell>
                    </TableRow>
                    <TableRow>
                      <CCell css={{border:'none'}}>日期：</CCell>
                      <Cell css={{border:'none'}}>2024/03/04</Cell>
                    </TableRow>
                  </TableBody>
                </Table>
              </div>
            </CCell>
          </TableRow>
        </RepLink>
        <TableRow>
          <CCell>审核</CCell>
          <CCell></CCell>
          <CCell>日期</CCell>
          <CCell></CCell>
        </TableRow>
        <TableRow >
          <CCell>批准</CCell>
          <CCell></CCell>
          <CCell>日期</CCell>
          <CCell></CCell>
        </TableRow>
      </TableBody>
    </Table>
  </>;
};
